//
//  TransactionCodeInputView.swift
//  zhonglb_iOS
//
//  Created by lxm on 2021/12/1.
//

import UIKit

class TransactionCodeInputView: XMBaseView, XMCodeInputViewDelegate {
    
    @IBOutlet weak var codeInputView: XMCodeInputView!

    var forgetClick : (()->())?
    
    var compete : ((_ psd : String)->())?
    
    @IBOutlet weak var allMoney: UILabel!
    
    @IBOutlet weak var leftTip: UILabel!
    
    @IBOutlet weak var rightTip: UILabel!
    
    @IBOutlet weak var unit: UILabel!
    
    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var centerTip: UILabel!
    
    @IBOutlet weak var pointLabel: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        setUI()
    }
    
    func clear() {
        codeInputView.clear()
    }
    
    func beginEdit() {
        codeInputView.becomeFirstResponder()
    }
    
    func setUI() {
        codeInputView.inputCount = 6
        codeInputView.space = 4
        let con = XMCodeInputCellConfig()
        con.hideLine = true
        con.borderColor = "#EAEAEA".zm.hex()
        con.borderWidth = 1
        con.securityInput = true
        con.cornerRadius = 8
        codeInputView.cellConfig = con
        codeInputView.delegate = self
        codeInputView.reaload()
    }
    
    func inputComplete(_ text: String) {
        print(text)
        if let compete = compete {
            compete(text)
        }
    }
    
    func setprice(money : String, left : String, right : String) {
        self.allMoney.text = money
        self.leftTip.text = left
        self.rightTip.text = right
    }
    
    @IBAction func closeClick(_ sender: Any) {
        codeInputView.textField.resignFirstResponder()
        self.removeFromSuperview()
    }
    
}

